<template>
	<view style="background-color: whitesmoke;">

		<view v-for="c in projectList" class="flex-container cu-form-group" @click="toProjectDetail(c)">
			<view class="cu-form-group view-box" >{{c.projectName}}</view>
			<text class="cuIcon-more flex-item cu-form-group" style="background-color: white;" @tap.stop="moreProgrss(c)"></text>
		</view>
		<!-- cuIcon-more -->
		
		<!-- 悬浮框 -->
		<view>
			<!-- 悬浮框 -->
			<uni-fab class="uni-combox__input" 
				:pattern="pattern"
				:horizontal="horizontal"
				:vertical="vertical"
				:direction="direction"
				@trigger="trigger"
				@fabClick="fabClick"
			></uni-fab>
		</view> 
		
		<!-- <text style="padding: 35px;"></text> -->
	</view>
</template>

<script>
	import common from 'common/common.js';
	export default {
		data() {
			return {
				isRefresh:false,
				
				projectList: [],
				
				// 悬浮框
				horizontal: 'right',
				vertical: 'bottom',
				direction: 'horizontal',
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor:"#007AFF"
				},
				
				staff:{},
			}
		},
		mounted() {
		},
		onShow() {
			this.getProjectList();
			
		},
		onLoad() {
			this.staff = uni.getStorageSync("staff");
			this.getProjectList();
		},
		methods: {
			// 操作项目，修改和删除
			moreProgrss(project){
				this.project = project;
				 uni.navigateTo({
				        url: `/pages/project/projectSetting?projectId=${this.project.id}`,
				      });
			},
			// 跳转项目详细
			toProjectDetail(project){
				this.project = project;
				uni.navigateTo({
					url: `/pages/project/projectDetail?projectId=${this.project.id}`,
				})
			},
			// 查询列表
			getProjectList(){
				var _this = this;
				uni.request({
					url: common.api_base_url+'/okrproject/findAllByStaffId/' + _this.staff.id,
					data:{
					},
					header:{
					},
					method: 'GET',
					success: res => {
						_this.projectList = res.data;
					},
					fail: function(e) {
						uni.showToast({
							title:"唉哟，程序错误了["+JSON.stringify(e)+"]",
							icon:"loading"
						})
					},
				});
			},
			
			// 悬浮框点击事件
			fabClick(){
				uni.navigateTo({
					url: `/pages/project/addProject`
				})
			},
			
		}
	}
</script>

<style>
	.flex-container {
	  display: flex;
	  flex-direction: row; /* 垂直居中对齐 */
	}
	.flex-item {
	  border: 1px solid #ccc;
	  margin: 5px;
	  height: 25px; /* 设置元素的高度 */
	  border: none; /* 去掉边框 */
	}

	.view-box {
	 width: 90%;
	}

</style>
